//
//  MyBillVC.m
//  saler-ios
//
//  Created by 王亚陆 on 17/6/12.
//  Copyright © 2017年 sayimba. All rights reserved.
//

#import "MyBillVC.h"
#import "MyBillCell.h"
@interface MyBillVC ()
<
UITableViewDelegate,
UITableViewDataSource
>
{
    UIView * nav;
    RootViewController * TabBar;
    UITableView * Table;
}

@property (nonatomic,strong) UIView * backview1;
@property (nonatomic,strong) UIView * backview2;


@end

@implementation MyBillVC

- (void)viewDidLoad {
    [super viewDidLoad];
    nav = [self createNav:@"销售账单"];
    [self.view addSubview:nav];
    self.view.backgroundColor = UIviewBackColor;
    
    
    [self createView1];
    [self createView2];

}



-(void)createView1{
    
    
    _backview1 = [[UIView alloc]init];
    _backview1.backgroundColor = WhiteColor;
    [self.view addSubview:_backview1];
    [_backview1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.view.mas_left);
        make.top.mas_equalTo(nav.mas_bottom).with.offset(10*kHeight);
        make.size.mas_equalTo(CGSizeMake(Main_Width, Main_height-64));
    }];
    
    
    UIImageView * imageRound = [[UIImageView alloc]init];
    imageRound.backgroundColor = YellowColor;
    LRViewBorderRadius(imageRound, 45*kHeight, 90*kHeight, YellowColor);
    [_backview1 addSubview:imageRound];
    [imageRound mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(_backview1.mas_centerX);
        make.top.mas_equalTo(_backview1.mas_top).with.offset(17*kHeight);
        make.size.mas_equalTo(CGSizeMake(90*kWidth, 90*kHeight));
    }];
    
    UILabel * allMoney = [UILabel createUIlabel:@"总资产" andFont:FontOfSize14 andColor:WhiteColor];
    [_backview1 addSubview:allMoney];
    [allMoney mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(_backview1.mas_centerX);
        make.top.mas_equalTo(imageRound.mas_top).with.offset(26*kHeight);
    }];
    UILabel * MoneyLabel = [UILabel createUIlabel:@"1000" andFont:FontOfSize19 andColor:WhiteColor];
    [_backview1 addSubview:MoneyLabel];
    [MoneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(_backview1.mas_centerX);
        make.top.mas_equalTo(allMoney.mas_bottom).with.offset(7*kHeight);
    }];
    
    
    UIImageView * imageLeft = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"ticheng"]];
    [_backview1 addSubview:imageLeft];
    [imageLeft mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(_backview1.mas_left).with.offset(48*kWidth);
        make.top.mas_equalTo(_backview1.mas_top).with.offset(125*kHeight);
        make.size.mas_equalTo(CGSizeMake(12*kWidth, 12*kHeight));
    }];
    UILabel * labelLeft = [UILabel createUIlabel:@"已提成：2单" andFont:FontOfSize12 andColor:PriceColor];
    [_backview1 addSubview:labelLeft];
    [labelLeft mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(imageLeft.mas_right).with.offset(5*kWidth);
        make.centerY.mas_equalTo(imageLeft.mas_centerY);
    }];

    
    UILabel * labelRight = [UILabel createUIlabel:@"未提成：1单" andFont:FontOfSize12 andColor:PriceColor];
    [_backview1 addSubview:labelRight];
    [labelRight mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(_backview1.mas_right).with.offset(-48*kWidth);
        make.centerY.mas_equalTo(imageLeft.mas_centerY);
    }];

    UIImageView * imageRight = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"weiticheng"]];
    [_backview1 addSubview:imageRight];
    [imageRight mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(labelRight.mas_left).with.offset(-5*kWidth);
        make.centerY.mas_equalTo(imageLeft.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(12*kWidth, 12*kHeight));
    }];
    
    
    UIImageView * imageToday = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"date"]];
    [_backview1 addSubview:imageToday];
    [imageToday mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(_backview1.mas_right).with.offset(-20*kWidth);
        make.top.mas_equalTo(_backview1.mas_top).with.offset(17*kHeight);
        make.size.mas_equalTo(CGSizeMake(13*kWidth, 13*kHeight));
    }];

    
    UILabel * today = [UILabel createUIlabel:@"本日" andFont:FontOfSize11 andColor:PriceColor];
    [_backview1 addSubview:today];
    [today mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(imageToday.mas_left).with.offset(-8*kWidth);
        make.centerY.mas_equalTo(imageToday.mas_centerY);
    }];

    UILabel * pricelabel = [UILabel createUIlabel:@"账户明细" andFont:FontOfSize14 andColor:PriceLabelColor];
    [_backview1 addSubview:pricelabel];
    [pricelabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(_backview1.mas_centerX);
        make.top.mas_equalTo(labelRight.mas_bottom).with.offset(14*kHeight);
    }];
    
    UIView * leftLine = [[UIView alloc]init];
    leftLine.backgroundColor = PriceLineColor;
    [_backview1 addSubview:leftLine];
    [leftLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(_backview1.mas_left).with.offset(20*kWidth);
        make.centerY.mas_equalTo(pricelabel.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(142*kWidth, 0.5*kHeight));
    }];
    UIView * rightLine = [[UIView alloc]init];
    rightLine.backgroundColor = PriceLineColor;
    [_backview1 addSubview:rightLine];
    [rightLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(_backview1.mas_right).with.offset(-20*kWidth);
        make.centerY.mas_equalTo(pricelabel.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(142*kWidth, 0.5*kHeight));
    }];


    Table = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, Main_Width, 86*kHeight) style:UITableViewStylePlain];
    [Table setTableFooterView:[UIView new]];
//    Table.userInteractionEnabled = NO;
    [Table setSeparatorStyle:UITableViewCellSeparatorStyleNone];
    
    
    Table.delegate = self;
    Table.dataSource = self;
    [_backview1 addSubview:Table];
    [Table mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(_backview1.mas_left);
        make.top.mas_equalTo(pricelabel.mas_bottom);
        make.size.mas_equalTo(CGSizeMake(Main_Width, 55*7*kHeight));
    }];
    [Table reloadData];

    

    
    
}



-(void)createView2{
    
    
    
}

#pragma mark - 表单协议

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView
 numberOfRowsInSection:(NSInteger)section{
    
    return 7;
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView
         cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString  *CellIdentifier = @"CellIdentifier";
    
    MyBillCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    
    if (cell == nil) {
        
        cell = [[MyBillCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView
heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    return  55*kHeight;
    
}





- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    
    RootViewController *rootVC = [RootViewController defaultsTabBar];
    [rootVC setTabBarHidden:YES];
    
}


@end
